package com.studykun.client.ui;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class ChatBox extends Composite
{
  private FlowPanel chatClient_ = new FlowPanel();
  private FlowPanel chatPanel_ = new FlowPanel();
  private SimplePanel scrollTarget_ = new SimplePanel();
  
  public ChatBox()
  {
    chatClient_.add(chatPanel_);
    chatClient_.add(scrollTarget_);
    chatClient_.getElement().setClassName("chatBox");
    initWidget(chatClient_);
  }
  
  public void add(
      final Widget widget)
  {
    chatPanel_.add(widget);
    scrollTarget_.getElement().scrollIntoView();
  }
  
  public void add(
      final String text)
  {
    final InlineHTML inlineHtml = new InlineHTML(text);
    this.add(inlineHtml);
  }
}
